package controller;

import entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import serviceimpl.OrderDetailServiceImpl;
import serviceimpl.OrderServiceImpl;
import serviceimpl.UserServiceImpl;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    UserServiceImpl userService;

    @Autowired
    OrderServiceImpl orderService;

    @Autowired
    OrderDetailServiceImpl orderDetailService;

    @RequestMapping("/createOrder")
    @Transactional
    public String createOrder(@RequestParam String userName){

        return  orderService.createOrder(userName);
    }

    @RequestMapping("/pay")
    public String pay(@RequestParam String userName){

        return  orderService.updateOrder(userName);
    }

    @RequestMapping("/getOrderStatusNum")
    public List<String> getOrderStatusNum(@RequestParam String userName){

        return  orderService.getOrderStatusNum(userName);
    }

}
